import request from '@/utils/request'

// 查询订单列表
export function listOrder(query) {
  return request({
    url: '/restaurant/order/list',
    method: 'get',
    params: query
  })
}

// 查询订单详细
export function getOrder(id) {
  return request({
    url: '/restaurant/order/' + id,
    method: 'get'
  })
}

// 根据餐台ID查询进行中的订单
export function getOrderByTableId(tableId) {
  return request({
    url: '/restaurant/order/table/' + tableId,
    method: 'get'
  })
}

// 新增订单
export function addOrder(data) {
  return request({
    url: '/restaurant/order',
    method: 'post',
    data: data
  })
}

// 修改订单
export function updateOrder(data) {
  return request({
    url: '/restaurant/order',
    method: 'put',
    data: data
  })
}

// 删除订单
export function delOrder(ids) {
  return request({
    url: '/restaurant/order/' + ids,
    method: 'delete'
  })
}

// 点单
export function placeOrder(data) {
  return request({
    url: '/restaurant/order/place',
    method: 'post',
    data: data
  })
}

// 加单
export function addOrderItems(data) {
  return request({
    url: '/restaurant/order/add-items',
    method: 'post',
    data: data
  })
}

// 查询订单明细
export function getOrderDetails(orderId) {
  return request({
    url: '/restaurant/order/details/' + orderId,
    method: 'get'
  })
}

// 结账
export function checkoutOrder(data) {
  return request({
    url: '/restaurant/order/checkout',
    method: 'post',
    data: data
  })
}

// 查询已结账订单列表（订单中心）
export function getCheckedOutOrders(query) {
  return request({
    url: '/restaurant/order/checked-out',
    method: 'get',
    params: query
  })
}

// 查询订单详情（包含订单明细）
export function getOrderDetail(orderId) {
  return request({
    url: '/restaurant/order/detail/' + orderId,
    method: 'get'
  })
}

